<html>
<head><meta charset="utf-8"><title>PackageId to project root directory unambiguously? · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html">PackageId to project root directory unambiguously?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="221058852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221058852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221058852">(Dec 28 2020 at 12:59)</a>:</h4>
<p>Is there a way to go from a <code>PackageId</code> to the source directory of the package on the local filesystem unambiguously? As an external consumer, not internally within cargo.</p>



<a name="221058861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221058861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221058861">(Dec 28 2020 at 12:59)</a>:</h4>
<p>e.g. as somebody who's consuming cargo's json messages?</p>



<a name="221072197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221072197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221072197">(Dec 28 2020 at 16:27)</a>:</h4>
<p><code>cargo metadata</code> has <code>.packages[].manifest_path</code></p>



<a name="221072287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221072287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221072287">(Dec 28 2020 at 16:28)</a>:</h4>
<p>and <code>.packages[].targets[].src_path</code></p>



<a name="221072883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221072883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221072883">(Dec 28 2020 at 16:36)</a>:</h4>
<p>I have no idea where to run <code>cargo metadata</code> in the first place.</p>



<a name="221072894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221072894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221072894">(Dec 28 2020 at 16:36)</a>:</h4>
<p>Because i don't know what the package root, or its manifest is.</p>



<a name="221072923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221072923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221072923">(Dec 28 2020 at 16:37)</a>:</h4>
<p>cargo metadata should find the manifest the same way cargo does, by traversing up the directory tree</p>



<a name="221073002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221073002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nemo157 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221073002">(Dec 28 2020 at 16:38)</a>:</h4>
<p>oh, you _just_ have a PackageId without being within the context of some project?</p>



<a name="221073041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221073041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221073041">(Dec 28 2020 at 16:39)</a>:</h4>
<p>That's correct. Well, technically I have an <code>compiler-artifact</code> JSON message, it also contains the <code>src_path</code>, That's what I use right now and then walk up directories to find a package manifest, but its unreliable.</p>



<a name="221073066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221073066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221073066">(Dec 28 2020 at 16:39)</a>:</h4>
<p>A simplest example here is probably being within a workspace (i.e. running cargo with <code>--all</code>)</p>



<a name="221073125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/PackageId%20to%20project%20root%20directory%20unambiguously%3F/near/221073125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/PackageId.20to.20project.20root.20directory.20unambiguously.3F.html#221073125">(Dec 28 2020 at 16:40)</a>:</h4>
<p>FWIW I made <a href="https://github.com/rust-lang/cargo/pull/9022">https://github.com/rust-lang/cargo/pull/9022</a> but its unclear to me if its something that's necessary yet.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>